<!--<?php
include_once PrintEot('header');
if(empty($action)){
print <<<EOT
-->
<form action="$admin_file" method="post" name="form">

    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td align="left" class="tittab">
                <strong>广告计划管理 &gt;&gt; 计划基本信息</strong>
            </td>
        </tr>
    </table>
    <table id="Table50" border="0" cellpadding="0" cellspacing="1" width="98%" align=center>
         <tr>
            <td colspan=2 height=30 class="zmenu"><b>数据分类：</b>
<!--
EOT;
 showPageLink("all", "1", "全部数据");
 showPageLink("audit", "0", "等待审核"); 
 showPageLink("audit", "1", "审核通过"); 
 showPageLink("audit", "2", "审核未通过");
print <<<EOT
-->
            </td></tr> 
            <tr>
            <td><b>快速查询：</b><select id="searchtype">
								<option value="name" selected>计划名称</option>
								<option value="shortname">客户简称</option>
								<option value="contractname">合同名称</option>							
							</select>
							<input type="text" name="searchkey" value="$searchkey" class="text"/>
							<input type="button" name="btnQuery" value="查询" class="text"/>
						</td>
            <td align="right" valign="center">
                <table id="Table51" border="0" cellpadding="0" cellspacing="5" height="30">
                    <input name="allSelect" type="hidden" value="all" />
                    <tr>
                        <td align="middle" valign="center">
                            <a href="javascript:document.location.reload();">
                                <img align="absMiddle" border="0" height="15" src="$imgpath/admin/reserch.gif" style="text-decoration: underline" width="17" />
                                <span style="color: #547054"> 刷新</span></a>
<!--
EOT;
						if($canaudit==true){
							showButton(4,'审批','javascript:showAudit("'.$admin_file.'&action=audit'.$transtr.'&curpage='.$curpage.'");');
						}
						if($canadd==true){
							showButton(1,'新增',$admin_file.'&action=new'.$transtr);
						}
						if($candel==true){
							showButton(2,'删除','javascript:ConfirmDel("'.$admin_file.'&action=del'.$transtr.'&Page='.$curpage.'","此操作不可恢复,确认删除吗？");');
						}print <<<EOT
-->
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="2" colspan=2>
            </td>
        </tr>
    </table>
    <div class="tab">
        <table id="Table52" border="0" cellpadding="3" cellspacing="0" align=center>
            <tr>
                <td align="middle" class="title" height="20" valign="center">序号</td>
                <td align="middle" class="title" height="20" valign="center">
                    <input id="Checkbox1" name="as" onclick="allchecked()" type="checkbox" />全选
                </td>
                <td align="middle" class="title" height="20" valign="center">计划名称</td>
                <td align="middle" class="title" height="20" valign="center">对应客户</td>
                <td align="middle" class="title" height="20" valign="center">支付标准</td>
                <td align="middle" class="title" height="20" valign="center">每日限额</td>                 
                <td align="middle" class="title" height="20" valign="center">提交申请数</td>               
                <td align="middle" class="title" height="20" valign="center">添加日期</td>
                <td align="middle" class="title" height="20" valign="center">审批</td>    
                <td align="middle" class="title" height="20" valign="center">状态</td>                    
                <td align="middle" class="title" height="20" valign="center">操作</td>
            </tr>
<!--
EOT;
$curidx = ($curpage-1)*$perpage;
$curpageidx = 0;
$showcount = count($db_advlist); 
foreach($db_advlist as $adv ){
	$merchant = getMerchant($adv[mer_id]);
	$curidx = $curidx+1;
	$curpageidx = $curpageidx+1;
	$cdate = date('Y/m/d H:i:s',$adv[create_time]);
	$feetype = $cfg_advfeetype[$adv[fee_type]];
	$advaudit = $cfg_userstatus[$adv[audit]];
	$advstatus = $cfg_merccstatus[$adv[status]];
print <<<EOT
--> 
            <tr height="20"  onclick="SwitchTd(this,'click',$curpageidx);" onmouseout="SwitchTd(this,'out',$curpageidx);" onmouseover="SwitchTd(this,'over',$curpageidx);" style="cursor: hand">
                <td align="middle" valign="center" height="20">$curidx </td>
                <td align="middle" valign="center"><input id="ids" name="ids" type="checkbox" value="$adv[id]" />
                </td>
                <td align="middle" valign="center">&nbsp;<a href="$basename?job=detail&action=advertise&curid=$adv[id]$transtr&backurl=$backurl" class=NoLine>$adv[name]</a></td>
                <td align="middle" valign="center">&nbsp;<a href="$basename?job=detail&action=merchant&curid=$adv[mer_id]$transtr&backurl=$backurl" class=NoLine>$adv[mer_name]</a></td>
                <td align="middle" valign="center">&nbsp;$feetype</td>
                <td align="middle" valign="center">&nbsp;$adv[day_maxmoney]</td>
                <td align="middle" valign="center">&nbsp;$adv[aff_count]</td>
                <td align="middle" valign="center">&nbsp;$cdate</td>
                <td align="middle" valign="center">&nbsp;$advaudit</td> 
                <td align="middle" valign="center">&nbsp;$advstatus</td>
                <td align="middle" valign="center">&nbsp;
<!--
EOT;
	showEditButton($adv[id]);
print <<<EOT
-->
                </td>
            </tr>
<!--
EOT;
}print <<<EOT
-->
        </table>
    </div>
    <table id="Table1" border="0" cellpadding="0" cellspacing="0" width="98%">
        <tr>
            <td>
                &nbsp;</td>
            <td align="right" height="35">
<!--
EOT;
	showPageBreakInfo($showcount);
print <<<EOT
-->
             &nbsp;</td>
        </tr>
    </table>
    <input type="hidden" id="count" name="count" value="$showcount" />

</form>

<!--
EOT;
}
if($action=="new" || $action=="edit"){
	if(isset($db_adv)){
		$start_time = date('Y-m-d',$db_adv[start_time]);
		$end_time = date('Y-m-d',$db_adv[end_time]);
	}
	$op_starthour = "";
	$op_endhour = "";
	for($i=0;$i<24;$i++){
		if($i<10) $hour = "0".$i;
		else $hour = $i;
		if(isset($db_advpage) && date('H',$adv[start_time])==$i)
			$op_starthour .= "<option value='".$i."' selected>".$hour."</option>";
		else
			$op_starthour .= "<option value='".$i."'>".$hour."</option>";
	}
	for($i=0;$i<24;$i++){
		if($i<10) $hour = "0".$i;
		else $hour = $i;
		if(isset($db_advpage) && date('H',$adv[end_time])==$i)
			$op_endhour .= "<option value='".$i."' selected>".$hour."</option>";
		else
			$op_endhour .= "<option value='".$i."'>".$hour."</option>";
	}
	$effsingleip = 0; $efflikeip=0; $effcodelike=0; $effrecodenum=0;$maxcrt=0;
	if(isset($db_adv)){
		$effsingleip = $db_adv[eff_singleip];
		$efflikeip = $db_adv[eff_likeip];
		$effcodelike = $db_adv[eff_codelike];
		$effrecodenum = $db_adv[eff_recodenum];
		$maxcrt = $db_adv[max_crt];
	}
print <<<EOT
-->
<form name="form" action="$admin_file" method="post" onsubmit="return checkfrm();" enctype="multipart/form-data">
<input type="hidden" name="action" id="action" value="save"/>
<input type="hidden" name="curid" id="curid" value="$curid"/>
<TABLE cellSpacing="0" cellPadding="0" width="100%" border=0 ID="Table22">
	<TBODY>
		<TR >
			<TD class="tittab" BACKGROUND="$imgpath/admin/menu_bg.gif"><strong><img src="$imgpath/admin/view.gif" width="15" height="13" align="absmiddle"> 新增/编辑　广告计划</strong></TD>
		</TR>
	</TBODY>
</TABLE>
<table cellspacing=0 cellpadding=0 width="100%" border=0 id="Table23">  
    <tbody>
      <tr>
        <td valign=top>
		<div class="addpro">
			<table cellSpacing="0" cellPadding="5" width="100%" align="center" border="0">
				<tr>
					<td class="zhuang12b" width="100%" bgColor="#E1EBE2"><b>&nbsp;&nbsp;&nbsp;&nbsp;基本信息</b></td>
				</tr>
			</table>		
		<table cellspacing=0 cellpadding=4 width="100%" border=0 align=center id="Table24">
        <tbody>
        <tr>
					<td align=right width=15%>所属客户(<font color="red">*</font>)：</td>
					<td style="width: 30%">
						<select id="mer_id" name="mer_id" style="WIDTH: 201px"><option value="">请选择...</option>$op_merchantlist</select>				    
					</td>				
					<td align=right>对应合同(<font color="red">*</font>)：</td>
					<td><select ID="contract_id" name="contract_id" style="WIDTH: 201px"><option value="">请选择...</option>$op_mercontractlist</select></td>
				</tr>
				<tr>
					<td align=right>广告名称(<font color="red">*</font>)：</td>
					<td>
					    <input type="text" id="name" name="name" style="WIDTH: 201px" value="$db_adv[name]"/>
					</td>
				
					<td align=right>广告类型(<font color="red">*</font>)：</td>
					<td>
					    <select ID="advtype" name="advtype" style="WIDTH: 201px"><option value="">请选择...</option>$op_advtypelist</select>
					</td>
				</tr>
				<tr>
					<td align=right>开始时间(<font color="red">*</font>)：</td>
					<td>
					  <input name="start_time" type="text" readonly id="start_time" style="WIDTH:102px" value="$start_time"><A href="javascript:OpenCalendar('start_time', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"><select ID="start_hour" name="start_hour">$op_starthour</select></A>
					</td>
					<td align=right>结束时间(<font color="red">*</font>)：</td>
					<td>
					    <input name="end_time" type="text" readonly id="end_time" style="WIDTH:102px" value="$end_time"><A href="javascript:OpenCalendar('end_time', false)"><IMG src="$imgpath/admin/icon-calendar.gif" align="absMiddle" border="0"><select ID="end_hour" name="end_hour">$op_endhour</select></A>
					</td>
				</tr>
				<tr>				
					<td align=right>活动Logo：</td>
					<td style="width: 322px">
					<INPUT id="file_logo" type="file" name="file_logo" style="width: 200px; height: 21px" />
<!--
EOT;
	if(isset($db_adv) && $db_adv[logo]){
		echo "<a href='".$db_adv[logo]."' target='_blank'><img src='".$db_adv[logo]."' border='0' height='60px' align='absmiddle' title='点击看原图'/></a>";
	}
print <<<EOT
-->					
					<br/>
					</td>
					<td bgColor="#ffffff" align=right>
					    投放优先级：
					</td>
					<td>
					    <input type="text" id="level" name="level" style="WIDTH: 40px" value="$db_adv[level]"/>(数字越大表示优先级越高)
					</td>	
				</tr>			
				<tr>
					<td bgColor="#ffffff" align=right>
					默认导向页面：</td>
					<td colspan="3">
					<select name="page_id" id="page_id" style="width:200px"><option value="">请选择...</option>$op_pagelist</select>
					</td>
				</tr>
				<tr>
					<td bgColor="#ffffff" align=right>
					数据记录：</td>
					<td>
<!--
EOT;
	if(isset($db_adv) && $db_adv[is_view]==1){
		echo '<input type="checkbox" id="is_view" name="is_view" value="1" Checked/><label for="is_view">记录显示</label>&nbsp;';
	}else{
		echo '<input type="checkbox" id="is_view" name="is_view" value="1"/><label for="is_view">记录显示</label>&nbsp;';
	}
	if(isset($db_adv) && $db_adv[is_click]==1){
		echo '<input type="checkbox" id="is_click" name="is_click" value="1" Checked/><label for="is_click">记录点击</label>&nbsp;';
	}else{
		echo '<input type="checkbox" id="is_click" name="is_click" value="1"/><label for="is_click">记录点击</label>&nbsp;';
	}
	if(isset($db_adv) && $db_adv[is_rolling]==1){
		echo '<input type="checkbox" id="is_rolling" name="is_rolling" value="1" Checked/><label for="is_rolling">参与轮播</label>&nbsp;';
	}else{
		echo '<input type="checkbox" id="is_rolling" name="is_rolling" value="1"/><label for="is_rolling">参与轮播</label>&nbsp;';	
	}
	if(isset($db_adv) && $db_adv[mer_onlyfee]==1){
		echo '<input type="checkbox" id="mer_onlyfee" name="mer_onlyfee" value="1" Checked/><label for="mer_onlyfee">只对服务商计费</label>&nbsp;';
	}else{
		echo '<input type="checkbox" id="mer_onlyfee" name="mer_onlyfee" value="1"/><label for="mer_onlyfee">只对服务商计费</label>&nbsp;';	
	}	
print <<<EOT
-->				
					</td>
					<td bgColor="#ffffff" align=right>防止作弊：</td>
					<td>
<!--
EOT;
	if(isset($db_adv) && $db_adv[filter_likeip]==1){
		echo '<input type="checkbox" name="filter_likeip" id="filter_likeip" value="1" checked/>过滤相似IP&nbsp;';
	}else{
		echo '<input type="checkbox" name="filter_likeip" id="filter_likeip" value="1"/>过滤相似IP&nbsp;';	
	}
	if(isset($db_adv) && $db_adv[filter_agentip]==1){
		echo '<input type="checkbox" name="filter_agentip" id="filter_agentip" value="1" checked/>过滤代理IP&nbsp;';
	}else{
		echo '<input type="checkbox" name="filter_agentip" id="filter_agentip" value="1"/>过滤代理IP&nbsp;';	
	}
	if(isset($db_adv) && $db_adv[filter_foreignip]==1){
		echo '<input type="checkbox" name="filter_foreignip" id="filter_foreignip" value="1" checked/>过滤国外IP&nbsp;';
	}else{
		echo '<input type="checkbox" name="filter_foreignip" id="filter_foreignip" value="1"/>过滤国外IP&nbsp;';	
	}
print <<<EOT
-->
						点击率上限<input type="text" id="max_crt" name="max_crt" style="WIDTH: 30px" value="$maxcrt"/>%
					</td>
				</tr>				
				<tr>
					<td align=right style="height: 57px">活动说明：</td>
					<td colspan=3 style="height: 57px">
					<textarea ID="memo" name="memo" style="Height:80px;Width:80%">$db_adv[memo]</textarea>
					</td>
				</tr>

    </tbody>

 </TABLE>
  
			<table cellSpacing="0" cellPadding="5" width="100%" align="center" border="0">
				<tr>
					<td class="zhuang12b" width="100%" bgColor="#E1EBE2">&nbsp;&nbsp;&nbsp;&nbsp;<b>计费信息</b></td>
				</tr>
			</table>		
		<table cellspacing=0 cellpadding=4 width="100%" border=0 align=center id="Table24">
        <tbody>
				<tr>
					<td align=right style="width: 15%">支付标准：</td>
					<td width="28%">
<!--
EOT;
	if(!isset($db_adv) || $db_adv[fee_type]==0){
		echo '<input type="radio" id="fee_type0" name="fee_type" Value="0" checked/><label for="fee_type0">CPC</label>';
	}else{
		echo '<input type="radio" id="fee_type0" name="fee_type" Value="0"/><label for="fee_type0">CPC</label>';
	}
	if($db_adv[fee_type]==1){
		echo '<input type="radio" id="fee_type1" name="fee_type" Value="1" checked/><label for="fee_type1">CPM</label>';
	}else{
		echo '<input type="radio" id="fee_type1" name="fee_type" Value="1"/><label for="fee_type1">CPM</label>';
	}
	if($db_adv[fee_type]==2){
		echo '<input type="radio" id="fee_type2" name="fee_type" Value="2" checked/><label for="fee_type2">CPA</label>';
	}else{
		echo '<input type="radio" id="fee_type2" name="fee_type" Value="2"/><label for="fee_type2">CPA</label>';
	}
	if($db_adv[fee_type]==3){
		echo '<input type="radio" id="fee_type3" name="fee_type" Value="3" checked/><label for="fee_type3">CPD</label>';
	}else{
		echo '<input type="radio" id="fee_type3" name="fee_type" Value="3"/><label for="fee_type3">CPD</label>';
	}		
print <<<EOT
-->
					</td>	
				    <td align=right>对帐URL：</td>
					<td>
					    <input type="text" id="bill_url" name="bill_url" value="$db_adv[bill_url]" style="WIDTH: 200px">
					</td>										
				</tr>
				<tr>
					<td align=right>广告商结算价(<font color="red">*</font>)：</td>
					<td>
						<input type="text" id="price" name="price" value="$db_adv[price]"/><select id="unit" name="unit" style="width:70px">$op_unitlist</select>
					</td>	
					<td bgColor="#ffffff" align=right>站长支付价(<font color="red">*</font>)：</td>
					<td>
					    <input type="text" id="aff_price" name="aff_price" value="$db_adv[aff_price]"/><select id="aff_unit" name="aff_unit" style="width:70px">$op_affunitlist</select>
					</td>				
				</tr>
				<tr>
					<td align=right>每日限额：</td>
					<td colspan="3">
						<input type="text" id="day_maxmoney" name="day_maxmoney" value="$db_adv[day_maxmoney]"/> 元
					</td>							
				</tr>							

				<tr>
					<td align="center" height="50px" colspan=4>
					<input type="submit" id="btnSubmit" value=" 确定 " class="text" NAME="btnSubmit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
					<input type="button" onclick="window.location='$admin_file$transtr';" value=" 取消 " class="text"/>
					</td>
				</tr>
         
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
 </form>

<script type="text/javascript" language=javascript>
function checkfrm(){
	if(isEmpty($("mer_id").value)){
		alert('请选择所属广告主！');
		$("mer_id").focus();
        return false;
	}
	if(isEmpty($("contract_id").value)){
		alert('请选择对应广告合同！');
		$("contract_id").focus();
        return false;
	}	
	if(isEmpty($('name').value)){
		alert('请输入广告名称！');
		$('name').focus();
		return false;
	}	
	if($('day_maxmoney').value == ""){
		alert('每日限额不能为空！');
		$('day_maxmoney').focus();
		return false;
	}else if(isNaN($('day_maxmoney').value)){
	    alert('每日限额必须为数字！');
	    $('day_maxmoney').focus();
		return false;
	}
	if(isEmpty($('level').value)){
		alert('优先级别不能为空！');
		$('level').focus();
		return false;
	}else if(isNaN($('level').value)){
	    alert('优先级别必须为数字！');
	    $('level').focus();
		return false;
	}
	if(isEmpty($('price').value)){
		alert('广告主结算价不能为空！');
		$('price').focus();
		return false;
	}else if(isNaN($('price').value)){
	    alert('广告主结算价必须为数字！');
	    $('price').focus();
		return false;
	}
	if(isEmpty($('aff_price').value)){
		alert('站长支付价不能为空！');
		$('aff_price').focus();
		return false;
	}else if(isNaN($('aff_price').value)){
	    alert('站长支付价必须为数字！');
	    $('aff_price').focus();
		return false;
	}	
    return true;
}

</script>

<!--
EOT;
}
if($action=="audit"){
print <<<EOT
-->
<form action="$admin_file" method="post" name="form" onsubmit="javascript:return checkfrm();">
<input type="hidden" name="action" value="auditsave"/>
<input type="hidden" name="ids" value="$ids"/>
<input type="hidden" name="status" value="$status"/>
<TABLE cellSpacing="0" cellPadding="0" width="100%" border=0 ID="Table22">
	<TBODY>	    
		<TR >
			<TD class="tittab" BACKGROUND="$imgpath/admin/menu_bg.gif">
			<strong><img src="$imgpath/admin/view.gif" width="15" height="13" align="absmiddle"> 审批广告计划</strong></TD>
		</TR>
	</TBODY>
</TABLE>
<table cellspacing=0 cellpadding=0 width="98%" border=0 id="Table23">  
    <tbody>
      <tr>
        <td valign=top>
		<div class="addpro">
		<table cellspacing=0 cellpadding=4 width="98%" border=0 align=center id="Table24">
            <tbody>
                <tr>
					<td align="right" width="15%">审批结果<font color=red>*</font>：</td>
					<td>
				 		<input type="radio" name="auditstatus" id='auditstatus1' value="1" checked onclick='javascript:$("content").value="广告计划内容信息准确，情况属实，允许通过！";'/><label for="auditstatus1">审核通过</label> 
				 		<input type="radio" name="auditstatus" id='auditstatus2' value="2" onclick='javascript:$("content").value="广告计划信息有误，不允许通过！";'/><label for="auditstatus2">审核不通过</label> 
					</td>
				</tr>
				<tr>
					<td align=right>审核内容：</td>
					<td><textarea name="content" id="content" style="width: 90%; height:55px">广告计划内容信息准确，情况属实，允许通过！</textarea></td>
				</tr>
				<tr>
					<td colspan="2" align="center">
					<input type="submit"  value=" 确定 " NAME="btnSubmit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
					<input type="button" onclick="window.close();" value=" 取消"/>
					</td>
				</tr>
         
    </tbody>
 </table>
 </div></TD>
  </TR>
 </TBODY>

 </TABLE>
 </form>
<script>
function checkfrm(){
	if(isEmpty($('content').value)){
		alert("请输入审批内容!");
	}
}
</script>
<!--
EOT;
}
?>-->